package com.instwall.callnumlistener.task;

import android.os.RemoteException;

import com.instwall.callbase.thread.BasicTask;
import com.instwall.callnumlistener.CallNumNotification;

public class NotificationTask extends BasicTask {

    private String data;

    public NotificationTask(String data) {
        this.data = data;
    }


    @Override
    public void doWork() {
        int n = CallNumNotification.mListeners.beginBroadcast();
        if (n == 0) {
            return;
        }
        if (data == null) return;
        try {
            for (int i = 0; i < n; i++) {
                try {
                    CallNumNotification.mListeners.getBroadcastItem(i).onNewCallNum(data);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
            CallNumNotification.mListeners.finishBroadcast();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void cancel() {

    }

    @Override
    public int getPriority() {
        return 0;
    }
}
